package jbox2dprocessing.compontent;

import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Body;

import pbox2d.PBox2D;
import processing.core.PApplet;

public class AbstractBox2DShape {
	Body baseBody;
	
	//	BaseBox Position
	public float baseX;
	public float baseY;
	
	//	BaseBox Shape
	public PBox2D box2d;
	
	public int baseColor;
	public int baseStrokeColor;
	public int baseStrokeWeight;
	
	//	The type of the physical items
	public String baseType;
	
	//	BaseBox Physics
	public float baseDensity;
	public float baseFriction;
	public float baseRestitution;
	
	//	Default Constants
	public static PApplet parent;
	public static float DEFAULTBASEX = 300;
	public static float DEFAULTBASEY = 400;
//	public static int DEFAULTBASECOLRO = parent.color(155);
//	public static int DEFAULTBASESTROKECOLOR = parent.color(0);
	public static int DEFAULTBASESTROKEWEIGHT = 2;
	public static float DEFAULTBASEDENSITY = 0;
	public static float DEFAULTBASEFRICTION = 0.3f;
	public static float DEFAULTBASERESTITUTION = 0.5f;
	
	/**
	 * The player this shape belongs to.
	 */
	public int master;

	
	public AbstractBox2DShape(PBox2D _box2d) {
		super();
		this.baseX = DEFAULTBASEX;
		this.baseY = DEFAULTBASEY;
		this.box2d = _box2d;
		this.baseColor = parent.color(155);
		this.baseStrokeColor = parent.color(0);
		this.baseStrokeWeight = DEFAULTBASESTROKEWEIGHT;
		this.baseDensity = DEFAULTBASEDENSITY;
		this.baseFriction = DEFAULTBASEFRICTION;
		this.baseRestitution = DEFAULTBASERESTITUTION;
	}
	
	public AbstractBox2DShape(PBox2D _box2d, float baseDensity){
		super();
		this.baseX = DEFAULTBASEX;
		this.baseY = DEFAULTBASEY;
		this.box2d = _box2d;
		this.baseColor = parent.color(155);
		this.baseStrokeColor = parent.color(0);
		this.baseStrokeWeight = DEFAULTBASESTROKEWEIGHT;
		this.baseDensity = baseDensity;
		this.baseFriction = DEFAULTBASEFRICTION;
		this.baseRestitution = DEFAULTBASERESTITUTION;
	}
	
	//	Default Color, physics attrs
	public AbstractBox2DShape(float baseX, float baseY, PBox2D _box2d) {
		super();
		this.baseX = baseX;
		this.baseY = baseY;
		this.box2d = _box2d;
		this.baseDensity = DEFAULTBASEDENSITY;
		this.baseFriction = DEFAULTBASEFRICTION;
		this.baseRestitution = DEFAULTBASERESTITUTION;
		
		this.baseColor = parent.color(155);
		this.baseStrokeColor = parent.color(0);
		this.baseStrokeWeight = DEFAULTBASESTROKEWEIGHT;

	}

	
	//	Define costumized BaseBox
	public AbstractBox2DShape(float baseX, float baseY, 
			PBox2D _box2d, float baseDensity, float baseFriction,
			float baseRestitution) {
		super();
		this.baseX = baseX;
		this.baseY = baseY;
		this.box2d = _box2d;
		this.baseDensity = baseDensity;
		this.baseFriction = baseFriction;
		this.baseRestitution = baseRestitution;
		
		this.baseColor = parent.color(155);
		this.baseStrokeColor = parent.color(0);
		this.baseStrokeWeight = DEFAULTBASESTROKEWEIGHT;
	}
	
	
	public AbstractBox2DShape(float baseX, float baseY, 
			PBox2D _box2d, int baseColor, int baseStrokeColor,
			int baseStrokeWeight, float baseDensity, float baseFriction,
			float baseRestitution) {
		super();
		this.baseX = baseX;
		this.baseY = baseY;
		this.box2d = _box2d;
		this.baseColor = baseColor;
		this.baseStrokeColor = baseStrokeColor;
		this.baseStrokeWeight = baseStrokeWeight;
		this.baseDensity = baseDensity;
		this.baseFriction = baseFriction;
		this.baseRestitution = baseRestitution;
	}
	
	public void display(){
		
	}
	
	public Vec2 getPos(){
		return box2d.getScreenPos(baseBody);
	}
	
	public float getAngle(){
		return baseBody.getAngle();
	}
	
	public boolean outOfScreen(){
		return false;
	}
}
